#pragma once

#include "data_processing_tool_global.h"
#include <gdal.h>
#include <gdal_priv.h>
#include <gdal_utils.h>
#include <string>
#include <vector>
#include <iostream>
using namespace std;

class DATA_PROCESSING_TOOL_EXPORT Data_Processing_Tool
{
public:
    Data_Processing_Tool();
	~Data_Processing_Tool();
	void getFiles(string path, vector<string>& files, string filePostFix);
	int calCol(double lng, double lat, double* geoTransform);
	int calRow(double lng, double lat, double* geoTransform);
	void HDF5_to_GeoTiff(vector<string> files, string outPutFileDir, string SDS_Name, string product_Name);
	float NTLImageAverageCal(string filePath, int nBlockSize);
	vector<double> NTLImageAverageCal(string filePath, vector<double*> points, int windowSize);
	void writeGeoTiff(GDALDataset* poDataset, string format, string saveFilePath, int dataType, int blockSize, int width, int height, int nBands);

private:
	void eachFile_HDF5_to_GeoTiff(string filePath, int subSDS_Index, string outPutFileDir, vector<string> existedOutputFiles);
	int getVNP46A3_4SDSIndex(string SDS_Name);
	int getVNP46A2SDSIndex(string SDS_Name);
	int getVNP46A1SDSIndex(string SDS_Name);
	float calNTLSum(float* imageArray, int nXBlock, int nYBlock, int nBands);
	double calNTLWindowAve(float* imageArray, int windowSize, int nBands);
	
	GDALDataset* WriteTif_Byte(GDALDriver *saveDriver, GDALDataset *poDataset, string saveFilePath, unsigned char* pafScan, int width, int height, int nBands, int col_start, int row_start, double *geoTransform);
	GDALDataset* WriteTif_UInt16(GDALDriver *saveDriver, GDALDataset *poDataset, string saveFilePath, unsigned short* pafScan, int width, int height, int nBands, int col_start, int row_start, double *geoTransform);
	GDALDataset* WriteTif_Int16(GDALDriver *saveDriver, GDALDataset *poDataset, string saveFilePath, short* pafScan, int width, int height, int nBands, int col_start, int row_start, double *geoTransform);
	GDALDataset* WriteTif_UInt32(GDALDriver *saveDriver, GDALDataset *poDataset, string saveFilePath, unsigned long* pafScan, int width, int height, int nBands, int col_start, int row_start, double *geoTransform);
	GDALDataset* WriteTif_Int32(GDALDriver *saveDriver, GDALDataset *poDataset, string saveFilePath, int* pafScan, int width, int height, int nBands, int col_start, int row_start, double *geoTransform);
	GDALDataset* WriteTif_Float32(GDALDriver *saveDriver, GDALDataset *poDataset, string saveFilePath, float* pafScan, int width, int height, int nBands, int col_start, int row_start, double *geoTransform);
	GDALDataset* WriteTif_Float64(GDALDriver *saveDriver, GDALDataset *poDataset, string saveFilePath, double* pafScan, int width, int height, int nBands, int col_start, int row_start, double *geoTransform);
};
